<script setup lang="ts">
import { useK8SApi } from "@/views/domain/kubeHud/api/k8s/k8s";
import { type Secret } from "@/views/domain/kubeHud/api/k8s/types";
import { onMounted, reactive, ref } from "vue";
import NamespaceSelector from "../namespace/widgets/NamespaceSelector.vue";
import KSecretList from "./widgets/KSecretList.vue";
import { useCreateSecret } from "./SecretCreate/createProvider";
import SecretCreate from "./SecretCreate/index.vue";
import { useRouter } from "vue-router";
import { KubeHudRouterPath } from "../../../router";

const { secretRepo } = useK8SApi();
const router = useRouter();

const query = reactive<{
  namespace?: string;
}>({ namespace: "default" });

const onShouldCreate = () => {
  router.push(KubeHudRouterPath.SecretCreate);
};
</script>

<template>
  <div class="w-full">
    <el-card>
      <el-form v-model="query" inline label-position="top">
        <el-form-item label="Namespace" prop="namespace">
          <NamespaceSelector v-model="query.namespace" />
        </el-form-item>
      </el-form>
      <div class="flex w-full justify-end">
        <el-button type="primary" icon="Plus" @click="onShouldCreate">
          <span>新建</span>
        </el-button>
      </div>
      <KSecretList :namespace="query.namespace" />
    </el-card>

    <SecretCreate />
  </div>
</template>
<style lang="scss" scoped></style>
